package com.ruoyi.goods.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.goods.domain.AllGood;
import com.ruoyi.goods.domain.AllIds;
import com.ruoyi.goods.service.IAllGoodService;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2022-05-08
 */
@RestController
@RequestMapping("/system/good")
public class AllGoodController extends BaseController
{
    @Autowired
    private IAllGoodService allGoodService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:good:list')")
    @GetMapping("/list")
    public TableDataInfo list(AllGood allGood)
    {
        startPage();
        List<AllGood> list = allGoodService.selectAllGoodList(allGood);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:good:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AllGood allGood)
    {
        List<AllGood> list = allGoodService.selectAllGoodList(allGood);
        ExcelUtil<AllGood> util = new ExcelUtil<AllGood>(AllGood.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:good:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(allGoodService.selectAllGoodById(id));
    }
    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:good:query')")
    @GetMapping("/detalis")
    public AjaxResult getdetalis()
    {
        return AjaxResult.success(allGoodService.getdetalis());
    }
    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:good:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AllGood allGood)
    {
        return toAjax(allGoodService.insertAllGood(allGood));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:good:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AllGood allGood)
    {
        return toAjax(allGoodService.updateAllGood(allGood));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:good:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(allGoodService.deleteAllGoodByIds(ids));
    }

    /**
     * 预约
     */
    @PreAuthorize("@ss.hasPermi('system:good:remove')")
    @PostMapping("/makeGood")
    public AjaxResult makeGood(@RequestBody AllIds allIds)
    {

        return toAjax(allGoodService.makeGood(allIds));
    }
}
